﻿using System;
using System.Collections.Generic;

/// <summary>
/// 聊天消息管理器
/// </summary>
public class MessageManager
{
    /// <summary>
    /// 聊天消息列表
    /// </summary>
    public List<Message> Messages { get; private set; }
    /// <summary>
    /// 收到消息事件
    /// </summary>
    public event Action<Message> OnMessageReceive;

    public MessageManager()
    {
        Messages = new List<Message>();
    }
    /// <summary>
    /// 添加消息
    /// </summary>
    /// <param name="msg">欲添加的消息</param>
    public void AddMessage(Message msg)
    {
        Messages.Add(msg);
        if(!msg.Sender.Equals(Singleton<Owner>.GetInstance()))
            OnMessageReceive(msg);
    }
}
